import { defineStore } from 'pinia'
import { cityList } from '../api/task'
interface City {
    label: string;
    value: string;
}

export const taskStore = defineStore({
    id: 'task',
    state: () => {
        return {
            cityValue: localStorage.getItem('city') ||  '北京',
            cityList: [] as City[],
            bannerList: [],
            positionList: [],
            screenList: {},
            hotSearchList: [],
            areaList: []
        }
    },
    actions: {
        setCityValue(value: string){
            this.cityValue = value
        },
        async getCityList(){
            interface City {
                label: string;
                value: string;
            }
            this.cityList = [
                {label: "北京", value: "1"},
                {label: "上海", value: "2"},
                {label: "天津", value: "3"},
                {label: "重庆", value: "4"},
                {label: "广州", value: "5"},
                {label: "深圳", value: "6"},
                {label: "成都", value: "7"},
                {label: "武汉", value: "8"},
                {label: "南京", value: "9"},
                {label: "西安", value: "10"},
                {label: "杭州", value: "11"},
                {label: "青岛", value: "12"},
                {label: "大连", value: "13"},
                {label: "宁波", value: "14"},
                {label: "厦门", value: "15"},
                {label: "苏州", value: "16"},
                {label: "佛山", value: "17"},
                {label: "长沙", value: "18"},
                {label: "郑州", value: "19"},
                {label: "济南", value: "20"},
                {label: "哈尔滨", value: "21"},
                {label: "长春", value: "22"},
                {label: "沈阳", value: "23"},
                {label: "昆明", value: "24"},
                {label: "南宁", value: "25"},
                {label: "海口", value: "26"},
                {label: "兰州", value: "27"},
                {label: "乌鲁木齐", value: "28"},
                {label: "呼和浩特", value: "29"},
                {label: "石家庄", value: "30"},
                {label: "太原", value: "31"},
                {label: "合肥", value: "32"},
                {label: "南昌", value: "33"},
                {label: "福州", value: "34"},
                {label: "贵阳", value: "35"},
                {label: "西宁", value: "36"},
                {label: "拉萨", value: "37"},
                {label: "银川", value: "38"},
                {label: "澳门", value: "39"},
                {label: "香港", value: "40"}
            ]
        },
        setCityList(data: any){
            this.cityList = data
        },
        setBannerList(data: any){
            this.bannerList = data
        },
        setPositionList(data: any){
            this.positionList = data
        },
        setScreenList(data: any){
            this.screenList = data
        },
        setHotSearchList(data: any){
            this.hotSearchList = data
        }
    }
})